//
//  MainDealCell.m
//  ieGou
//
//  Created by 潮汐 on 15-1-29.
//  Copyright (c) 2015年 chaox. All rights reserved.
//

#import "MainDealCell.h"

@implementation MainDealCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.BigImageView = [[UIImageView alloc]init];
//        self.BigImageView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.BigImageView];
        [_BigImageView release];
        
        self.moneyView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.moneyView];
        [_moneyView release];
        
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.text = @"test";
        self.nameLabel.font = [UIFont systemFontOfSize:20];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.introduceLabel = [[UILabel alloc]init];
        self.introduceLabel.textColor = [UIColor lightGrayColor];
        self.introduceLabel.font = [UIFont systemFontOfSize:12];
        self.introduceLabel.numberOfLines = 2;
        self.introduceLabel.text = @"test";
        [self.contentView addSubview:self.introduceLabel];
        [_introduceLabel release];
        
        self.priceLabel = [[UILabel alloc]init];
        self.priceLabel.text = @"test";
        self.priceLabel.textColor = [UIColor colorWithRed:233 / 255.0 green:80/255.0 blue:63/255.0 alpha:1];
        self.priceLabel.font = [UIFont boldSystemFontOfSize:24];
        [self.contentView addSubview:self.priceLabel];
        [_priceLabel release];
        
        self.oldPriceLabel = [[UILabel alloc]init];
        self.oldPriceLabel.text = @"test";
        [self.contentView addSubview:self.oldPriceLabel];
        [_oldPriceLabel release];
        
        self.lineView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.lineView];
        [_lineView release];
        
        self.distanceLabel = [[UILabel alloc]init];
        self.distanceLabel.text = @"test";
        self.distanceLabel.font = [UIFont systemFontOfSize:14];
        self.distanceLabel.textColor =[UIColor colorWithRed:61 / 255.0 green:83/255.0 blue:121/255.0 alpha:1];
        [self.contentView addSubview:self.distanceLabel];
        [_distanceLabel release];
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.BigImageView.frame = CGRectMake(10, 10, 150, 100);
    self.nameLabel.frame = CGRectMake(175, 7, 190, 30);
    self.introduceLabel.frame = CGRectMake(175, 38, 190, 40);
    
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:13]};
    CGSize size = [self.priceLabel.text boundingRectWithSize:CGSizeMake(100, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    self.priceLabel.frame = CGRectMake(190, 82, size.width+25, 20);
    self.moneyView.frame = CGRectMake(173, 82, 20, 20);
    
    self.oldPriceLabel.frame = CGRectMake(215 + size.width, 84, 50, 20);
    self.lineView.frame =CGRectMake(215 + size.width, 88, 30, 20);
    self.distanceLabel.frame = CGRectMake(290, 85, 80, 20);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)dealloc
{
    [_BigImageView release];
    [_nameLabel release];
    [_introduceLabel release];
    [_priceLabel release];
    [_oldPriceLabel release];
    [_distanceLabel release];
    [_moneyView release];
    [_lineView release];
    [super dealloc];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
